/*     */ package com.cr.common.core.domain;
/*     */ 
/*     */ import com.cr.common.utils.MyStringUtils;
/*     */ import java.util.HashMap;
/*     */ 
/*     */ public class AjaxResult extends HashMap<String, Object> {
/*     */   private static final long serialVersionUID = 1L;
/*     */   
/*     */   public static final String CODE_TAG = "code";
/*     */   
/*     */   public static final String MSG_TAG = "msg";
/*     */   
/*     */   public static final String DATA_TAG = "data";
/*     */   
/*     */   public enum Type {
/*  30 */     SUCCESS(0),
/*  32 */     WARN(301),
/*  34 */     ERROR(500);
/*     */     
/*     */     private final int value;
/*     */     
/*     */     Type(int value) {
/*  39 */       this.value = value;
/*     */     }
/*     */     
/*     */     public int value() {
/*  44 */       return this.value;
/*     */     }
/*     */   }
/*     */   
/*     */   public AjaxResult() {}
/*     */   
/*     */   public AjaxResult(Type type, String msg) {
/*  63 */     super.put("code", Integer.valueOf(type.value));
/*  64 */     super.put("msg", msg);
/*     */   }
/*     */   
/*     */   public AjaxResult(Type type, String msg, Object data) {
/*  76 */     super.put("code", Integer.valueOf(type.value));
/*  77 */     super.put("msg", msg);
/*  78 */     if (MyStringUtils.isNotNull(data))
/*  80 */       super.put("data", data); 
/*     */   }
/*     */   
/*     */   public AjaxResult put(String key, Object value) {
/*  94 */     super.put(key, value);
/*  95 */     return this;
/*     */   }
/*     */   
/*     */   public static AjaxResult success() {
/* 105 */     return success("操作成功");
/*     */   }
/*     */   
/*     */   public static AjaxResult success(Object data) {
/* 115 */     return success("操作成功", data);
/*     */   }
/*     */   
/*     */   public static AjaxResult success(String msg) {
/* 126 */     return success(msg, null);
/*     */   }
/*     */   
/*     */   public static AjaxResult success(String msg, Object data) {
/* 138 */     return new AjaxResult(Type.SUCCESS, msg, data);
/*     */   }
/*     */   
/*     */   public static AjaxResult warn(String msg) {
/* 149 */     return warn(msg, null);
/*     */   }
/*     */   
/*     */   public static AjaxResult warn(String msg, Object data) {
/* 161 */     return new AjaxResult(Type.WARN, msg, data);
/*     */   }
/*     */   
/*     */   public static AjaxResult error() {
/* 171 */     return error("操作失败");
/*     */   }
/*     */   
/*     */   public static AjaxResult error(String msg) {
/* 182 */     return error(msg, null);
/*     */   }
/*     */   
/*     */   public static AjaxResult error(String msg, Object data) {
/* 194 */     return new AjaxResult(Type.ERROR, msg, data);
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-common-4.7.0.jar!\com\cr\common\core\domain\AjaxResult.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */